<?php
/**
 * 模块：默认功能区
 * @copyright (C)2011 Cenwor Inc.
 * @author Moyo <dev@uuland.org>
 * @package module
 * @name index.mod.php
 * @version 1.0
 */
class ModuleObject extends MasterObject
{
	function ModuleObject( $config )
	{
		$this->MasterObject($config);
		$runCode = Load::moduleCode($this);
		$this->$runCode();
	}
	function Main()
	{
		$clientUser = get('u', 'int');
		if ( $clientUser != '' )
		{
			handler('cookie')->setVar('finderid', $clientUser);
			handler('cookie')->setVar('findtime', time());
		}
		
		$data = logic('product')->display();
				 if (!$data && get('page', 'int') == 0)
		{
			header('Location: '.rewrite('?mod=subscribe&code=mail'));
			exit;
		} 
		$product = $data['product'];
		$this->Title = $data['mutiView'] ? '' : $product['name'];
		$data['mutiView'] || mocod('product.view');
		$data['mutiView'] || productCurrentView($product);
				$favorited = logic('favorite')->get_one($product['id']);
				if(INDEX_DEFAULT === true && ini('settings.template_path') == 'meituan'){
			$new_product = logic('product')->GetNewList(10);
		}
		$seller = logic('seller')->IndexGetList(logic('misc')->City('id'), logic('catalog')->Filter(get('catalog'), 'seller'));
		include handler('template')->file($data['file']);
	}
	
	function xinban(){
		$clientUser = get('u', 'int');
		if ( $clientUser != '' )
		{
			handler('cookie')->setVar('finderid', $clientUser);
			handler('cookie')->setVar('findtime', time());
		}
		
		$data = logic('product')->display();
		
		$product = $data['product'];
		$this->Title = $data['mutiView'] ? '' : $product['name'];
		$data['mutiView'] || mocod('product.view');
		$data['mutiView'] || productCurrentView($product);
		$favorited = logic('favorite')->get_one($product['id']);
		if(INDEX_DEFAULT){
			$new_product = logic('product')->GetNewList(2);
		}
		include handler('template')->file(home_new);
	}
	
	function pin(){
		$clientUser = get('u', 'int');
		if ( $clientUser != '' )
		{
			handler('cookie')->setVar('finderid', $clientUser);
			handler('cookie')->setVar('findtime', time());
		}
	
		$data = logic('product')->display();
	
		$product = $data['product'];
		$this->Title = $data['mutiView'] ? '' : $product['name'];
		$data['mutiView'] || mocod('product.view');
		$data['mutiView'] || productCurrentView($product);
		$favorited = logic('favorite')->get_one($product['id']);
		if(INDEX_DEFAULT){
			$new_product = logic('product')->GetNewList(2);
		}
		$seller = logic('seller')->GetList(logic('misc')->City('id'), logic('catalog')->Filter(get('catalog'), 'seller'));
		include handler('template')->file(home_bak);
	}
	
	function citylist(){
		include handler('template')->file('city_list');
	}
	
	function ExpressConfirm()
	{
		$oid = $this->Get['id'];
		$result = $this->OrderLogic->orderExpressConfirm($oid);
		if ( $result )
		{
			$this->Messager(__('已经确认收货，本次交易完成！'), '?mod=me&code=order');
		}
		else
		{
			$this->Messager(__('无效的订单号！'), '?mod=me&code=order');
		}
	}
	/*
	function updatepre(){
	 
		$sql = 'SELECT * from  '.table('metas').' ';
		$metas = dbc(DBCMax)->query($sql)->done();
		foreach ($metas as $val){
			if (substr($val['key'],0,21)=='p_presell_price_full_'){
				$array=explode('_',$val['key']);
				dbc()->SetTable(table('product'));
				$ary =  array(
				'preprice'=>$val['val'],
				'pretext'=>'预付'
				
				);
				dbc()->Update($ary, 'id = '.$array[4]);
			}
		}
		echo 'success'; 
		echo 'haha';

	}*/
	
	/* function delpre(){
		$sql = 'SELECT * from  '.table('metas').' ';
		$metas = dbc(DBCMax)->query($sql)->done();
		foreach ($metas as $val){
			if (substr($val['key'],0,15)=='p_presell_text_'){
				dbc(DBCMax)->delete('metas')->where('id='.$val['id'])->done();
			}
		}
		echo 'success';
	} */
}
?>